package com.own.business.system.menu.entity.dto;

import com.own.business.system.menu.entity.bo.SystemRolePermissionBo;
import com.own.component.common.base.entity.BaseDto;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * SystemRolePermissionDto
 *
 * @author chenxueli
 * @date 2024-03-31 09:22:58
 */
@Schema(title = "系统角色权限" + ConstantBeanSuffix.DTO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class SystemRolePermissionDto extends BaseDto<SystemRolePermissionBo> implements Serializable {

    @Schema(title = "角色id")
    private Long roleId;

    @Schema(title = "菜单id")
    private Long menuId;

    @Schema(title = "权限标识")
    private String permission;

    /**
     * 转业务层对象
     *
     * @param entity 原业务层对象
     * @return 业务层对象
     */
    @Override
    public SystemRolePermissionBo toBo(SystemRolePermissionBo entity) {
        if (entity == null) {
            entity = new SystemRolePermissionBo();
        }
        entity.setRoleId(this.roleId);
        entity.setMenuId(this.menuId);
        entity.setPermission(this.permission);
        return super.toBo(entity);
    }

}

